package controller;

import dao.collectDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/controller")
public class collect {
    @Autowired
public collectDao collectDao;
@RequestMapping("/showUserConsume")
@ResponseBody
public Map<String,Object> showUserConsume(String userName,String iphoneNum,int offset,int limit){
    if(userName!=null){
        try {
            userName = new String(userName.getBytes("ISO-8859-1"), "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    Map<String,Object> map=new HashMap<>();
    map.put("rows",collectDao.showUserConsume(userName,iphoneNum,offset,limit));
    map.put("total",collectDao.UserTotalConsume(userName,iphoneNum));
    return map;
}
}
